package com.itheima.homework;
import java.util.Scanner;
/*2、【编号：802】 已知用户名和密码，请用程序实现模拟用户登录。
        总共给三次机会，是否登录成功，给出相应的提示。*/
public class Test2 {
    public static void main(String[] args) {
        String userName = "admin";
        String passWord = "123456";
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i <=2 ; i++) {
            System.out.println("请输入用户名:");
            String scUserName = sc.nextLine();
            System.out.println("请输入密码:");
            String scPassWord = sc.nextLine();
            if(userName.equals(scUserName)&&passWord.equals(scPassWord)){
                System.out.println("登录成功");
                break;
            }else if(i==2) {
                System.out.println("今日登录次数已达上限,请改日再试");

            }else{
                System.out.println("登录失败,您还有"+(2-i)+"次机会");
            }

        }
    }
}
